﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RecipeTracker
{
    /// <summary>
    /// The Ingredient class encapsulates the different parts of an ingredient.
    /// 
    /// Class contains an internal public enum IngredientMeasure.
    /// </summary>
    public class Ingredient : IComparable
    {
        /// <summary>
        /// Contains the measure type.
        /// Cups, Teaspoons, etc...
        /// </summary>
        public IngredientMeasure Measure
        {
            get;
            set;
        }

        /// <summary>
        /// The name of the ingredient
        /// </summary>
        public string Name
        {
            get;
            set;
        }

        /// <summary>
        /// Amount of the ingredient to use
        /// </summary>
        public float Amount
        {
            get;
            set;
        }

        /// <summary>
        /// Creates an ingredient taking the name and measure as parameters
        /// </summary>
        /// <param name="name">The name of the Ingredient</param>
        /// <param name="measure">The measure type of the Ingredient</param>
        /// <param name="amount">The amount to use usually based on IngredientMeasure</param>
        public Ingredient(string name, IngredientMeasure measure, float amount)
        {
            Name = name;
            Measure = measure;
            Amount = amount;
        }

        /// <summary>
        /// Default Constructor
        /// </summary>
        public Ingredient() { }

        /// <summary>
        /// Presents the Ingredient as a normal string like would be written on a recipe card
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return Amount.ToString() + " " + Measure.ToString() + " " + Name;
        }

        /// <summary>
        /// Enum that contains the choices of measures for recipes.
        /// 
        /// This is an interal enum of Ingredient
        /// </summary>
        public enum IngredientMeasure
        {
            Can,
            Cans,
            Cube,
            Cubes,
            Cup,
            Cups,
            Teaspoon,
            Teaspoons,
            Tablespoon,
            Tablespoons,
            Package,
            Packages,
            Pound,
            Pounds,
            Pinch,
            Pinches,
            Ounce,
            Ounces,
            None
        }

        #region IComparable Members

        public int CompareTo(object obj)
        {
            if (obj is Ingredient)
            {
                Ingredient in2 = (Ingredient)obj;
                return Name.CompareTo(in2.Name);
            }
            else
                throw new ArgumentException("obj is not a valid Ingredient");
        }

        #endregion
    }
}
